﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Common;
using Core;

namespace MyCart.Controllers
{
    public class CategoryApiController : BaseAPIController
    {
        private readonly ICategoryRepository _CategoryRepository;
        public CategoryApiController(ICategoryRepository catRepo
            )
        {
            _CategoryRepository = catRepo;
        }
        // GET api/categories
        public IEnumerable<Category> Get()
        {
            return _CategoryRepository.GetAll();
        }

        // GET api/categories/5
        public Category Get(int id)
        {
            return _CategoryRepository.GetById(id);
        }

        // POST api/categories
        public void Post(Category cat)
        {
            _CategoryRepository.AddUpdate(cat);
        }

        // DELETE api/categories/5
        public void Delete(int id)
        {
            _CategoryRepository.Delete(id);
        }
    }
}
